const connection = require('../db/mysql')

class QuestionService {
  async question () {
    const statement = "SELECT qd.*, qt.name name FROM question_detail qd LEFT JOIN question_type qt ON qd.typeId = qt.type;"
    const [result] = await connection.execute(statement)
    return result;
  }
  async typeIdInfo (typeId) {
    const statement = "SELECT qd.*, qt.name name FROM question_detail qd LEFT JOIN question_type qt ON qd.typeId = qt.type WHERE qd.typeId = ?;"
    const [result] = await connection.execute(statement, [typeId])
    return result;
  }
}

module.exports = new QuestionService()
